

<?php if($_SESSION['username']){ ?>
<div class="right_order">
   <div class="right_order_top">
     <h2>购物车</h2>
     <span class="shop_cart_num" id="tatalnum" style="display:none;">1</span> </div>
   <div class=" sub_right_order_main">
     <table class="order_table" border="1" width="216px">
       <tbody><tr>
         <th class="order_table_th1"><span>品名</span></th>
         <th class="order_table_th2"><span>数量</span></th>
         <th class="order_table_th3"><span>价格</span></th>
         <th class="order_table_th"><span style="background:none;">取消</span></th>
       </tr>
     </tbody></table>
     <div class="order_detail" id="order_detail">
	<?php
	$total=0;
	$array=explode("@",$_SESSION[producelist]);
	$arrayquatity=explode("@",$_SESSION[quatity]);
	for($i=0;$i<count($array)-1;$i++){
		$id=$array[$i];
		$num=$arrayquatity[$i];

		if($id!=""){
			$sql=mysql_query("select * from tb_shangpin where id='".$id."'",$conn);
			$info=mysql_fetch_array($sql);
			$total1=number_format($num*$info[shichangjia],1);
			$total+=$total1;
			$_SESSION["total"]=number_format($total,1);
			?>
			<table  border="1" width="196px" style="margin-left:5px;table-layout:fixed;" id="cart_item_<?php echo $info['id'];?>" class="order_table">
				<tr>
					<td style="text-align:left" class="order_table_td2"><?php echo $info[mingcheng]; ?></td>
					<td class="order_table_td1">
						<span class="ft_b"><?php echo $num; ?></span>
					</td>
					<td class="order_table_td3">
						<?php echo $total1; ?>
					</td>
					<td>
						<a href="javascript:;" onClick="cart_item_delete(<?php echo $info['id']; ?>);">
						<img src="kfc_files/delete_icon.gif">
						</a>
					</td>
				</tr>
			</table>
	<?php
		}
	}
	?>



      </div>
	  <span class="order_price">小计:<span id="order_price"><?php echo $_SESSION["total"]; ?></span>元</span>

     <p class="al_c">
        <input name="gocart" class="order_btn_1" type="button" id="gocart" />
    </p>
    <p style="padding:0px 10px;"><span class="span_3">提醒：根据您最终提交订单时间，送餐时间可能略有调整。</span></p>
   </div>
   <div class=" sub_right_order_btm"> </div>
</div>  

<?php } else {?>
  <!-- 右侧订单 -->
<form action="chklogin.php" id="ff1" method="post">  
<!-- 右侧登陆 -->
<div class="right_order">

  <div class="right_order_top"><b>开始订餐</b></div>
  <div class="right_order_main">
    <h1>请输入手机号：</h1>
    <p>
      <input name="mobi" id="mobi" class="input_1" maxlength="50" type="text">
    </p>

    <p class="ersee-indexlogin" style="display:none;">
      <input id="input_reme" class="fl_l" value="" style="*margin:-7px 0 0;" type="checkbox">
      <span class="checkbox_txt fl_l">记住我</span>
    </p>
  </div>
  <!-- 【下一步】按钮 -->
  <div class="right_order_btm">
    <p class="login_btn">
    	<a looyu_bound="1" id="loginSubmit" href="javascript:void(0)">
    		<img src="kfc_files/next_btn.png">
    	</a>
      <!-- <input name="" type="button"  class="next_btn" onclick="showHide();"/> -->
    </p>

    <p class="txt_2 mt5px">友情提示：</p>
    <ul>
      <li>如果您曾使用我们的订餐服务，请输入您上次使用的电子邮箱或手机号码。</li>
    </ul>
  </div>
</div>
  </form>

<?php } ?>

<script type="text/javascript">
$(function() {
	$("#loginSubmit").click(function(){
		var tel=$("#mobi").val();

		if(!tel){
			alert("请输入手机号");
			return false;
		}
		$("#ff1").submit();

	});

	$('#gocart').click(function(){
		window.location="cart.php";
	});
});

function cart_item_delete(item_id){

		 $.ajax({
					type: "post",
					dataType: "json",
					url: "shopping/del_cart_item.php",
					data: {"id":item_id},
					success: function(data){
						if(data.flag==1){
							$('#cart_item_'+item_id).remove();
							$('#order_price').html(data.total);
						}
				}	
			});

}
</script>